﻿




using System.Collections.Generic;
using System.Linq;
using System.Web.Routing;
using Hotpot.Infrastructure;

namespace Hotpot.Extensions
{
    public static class RouteCollectionExtensions
    {
        public static void LoadFromModules(this RouteCollection routes, IModulesLoaded modulesLoaded)
        {
            IEnumerable<IHotpotModule> modules = modulesLoaded.GetModules().Reverse();

            foreach (IHotpotModule module in modules)
                module.RegisterRoutes(routes);
        }

        public static void LoadCatchAllFromModules(this RouteCollection routes, IModulesLoaded modulesLoaded)
        {
            IEnumerable<IHotpotModule> modules = modulesLoaded.GetModules().Reverse();

            foreach (IHotpotModule module in modules)
                module.RegisterCatchAllRoutes(routes);
        }
    }
}
